<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="/js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        $(function () {
            bindEvent()
        })
        function bindEvent() {
            $("#btn").click(function () {
                var sname=$("#sname").val();
                var cid=$("#cid").val();
                $.ajax({
                    url:"/com/zb/cn/add",
                    type:"post",
                    dataType:"json",
                    data:{"sname":sname,"cid":cid},
                    success:function (mes) {
                        var count=parseInt(mes);
                        if(count!=0){
                            window.location="/index.html";
                        }else{
                            window.location="/add.html";
                        }
                    }
                })
            })
        }
    </script>
</head>
<body>
    <div>
            <table>
                <tr>
                    <td>学生姓名:<input name="name" type="text" id="sname"></td>
                </tr>
                <tr>
                    <td>班级ID:<input  type="text" id="cid"></td>
                </tr>
                    <td><input id="btn" type="button" value="添加"></td>
                </tr>
            </table>
    </div>
</body>
</html>